export default {
  name: 'CRUDMixin',
  mounted() {
    if (this.configKey != this.$route.meta.configKey) {
      this.configKey = this.$route.meta.configKey;
    }
  },
  data() {
    return {
      funName: {
        Query: 1,     //1
        AdvQuery: 2,  //2
        Add: 3,       //4
        BatchAdd: 4,  //8
        Edit: 5,      //16
        Del: 6,       //32
        List: 7,      //64
        Footer: 8,    //128
        Expand: 9,    //256
        Tree:10,      //512
      },
      configKey: ''
    }
  },
  methods: {
    /**
      * @function 获取一个数值(fun)内的第几位(funNameIdx)是否为true
      * @param fun 数字值
      * @param funNameIdx 建议取值 this.funName.XXX  
      * @return bool
      */
    hasFlag(fun, funNameIdx) {
      /*
                  1   Query = 1,
                  2   Add = 2,
                  3   BatchAdd = 4,
                  4   Edit = 8,
                  5   Del = 16,
                  6   List = 32,
      */
      var val = (fun >> (funNameIdx - 1)) & 1;
      return val == 1;
    }
  }
}